#include <bits/stdc++.h>
#define sc(x) scanf("%lld", &(x))
#define pr(x) printf("%lld\n", (x))
#define rep(i, l, r) for (int i = l; i <= r; ++i)
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;
const int mod = 1e9 + 7;
char s[26][7][7];
int main() {
    rep(i, 0, 25) rep(j, 0, 6) scanf("%s", s[i][j]);
    string t, tmp = "";
    cin.ignore();
    getline(cin, t);
    vector<string> vs;
    for (int i = 0; i < t.length(); ++i) {
        int d = t[i] - 'A';
        if (d < 26 && d >= 0) {
            tmp += t[i];
            if (i == t.length() - 1) {
                vs.push_back(tmp);
            }
        } else if (i > 0 and isupper(t[i - 1])) {
            vs.push_back(tmp);
            tmp = "";
        }
    }

    for (int k = 0; k < vs.size(); ++k) {
        string t = vs[k];
        rep(i, 0, 6) {
            for (int j = 0; j < t.length(); ++j) {
                printf("%s%c", s[t[j] - 'A'][i],
                       j != t.length() - 1 ? ' ' : '\n');
            }
        }
        if (k != vs.size() - 1) putchar(10);
    }
    return 0;
}